
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>扫码检票</title>

    <!-- Bootstrap -->
    <link href="http://test.18bang.cn/addons/aide_ticket/static/css/bootstrap.min.css" rel="stylesheet">
    <!--[if lt IE 9]>
    <script src="https://cdn.bootcss.com/html5shiv/3.7.3/html5shiv.min.js"></script>
    <script src="https://cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
    </head>
<body style="background-color:#2a2a2a;">
<div class="main" style="min-height:800px;margin-top:30px;">
    <div class="info" style="width:605px;margin:200px auto;">
        <div class="input-group">
            <input type="text" id="key" class="form-control" placeholder="扫码设备光标处" aria-describedby="basic-addon2">
            <span class="input-group-addon btn" id="basic-addon2" onclick="javascript:window.opener=null;window.close();">扫码核销</span>
        </div>
        <div class="panel panel-default" style="margin-top:30px;">
            <div class="panel-heading">
                <h3 class="panel-title">票据信息</h3>
            </div>
            <div class="panel-body" id="info">
                
            </div>

        </div>
    </div>
</div>


<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="https://cdn.bootcss.com/jquery/1.12.4/jquery.min.js"></script>
<!-- Include all compiled plugins (below), or include individual files as needed -->
<script src="http://test.18bang.cn/addons/aide_ticket/static/js/bootstrap.min.js"></script>
<script src="http://test.18bang.cn/tp/public/plugins/layer/layer.js"></script>
<script>
    $(function () {
        var link_url;
        $("#key").focus();
        $("#key").change(function () {
            var content = $(this).val();
            var ruchangjuanId = 20; //入场券
            if(content.length<=0){
                return false;
            }else{
                var loadingFlag;
                var imei_num = "{$admin['name']}";
                var html = "";
                link_url = content;
                // alert(link_url);return false;
                $.ajax({
                    type:'POST',
                    url:"{php echo web_url('check/checking/checking');}",
                    data:{link_url:content,imei_num:imei_num},
                    dataType:"JSON",
                    success:function(res){
                        if(res.errcode == 0){
                            layer.msg(("票据"+res.errmsg),{time:1000});
                            showhtml(res.errmsg,res.data);
                            gofocus();
                        }else{
                            layer.alert(res.errmsg,function(index){
                                layer.close(index);
                                $("#info").empty();
                                gofocus();
                            });
                        }
                    },
                    error:function(){
                        layer.alert("网络连接失败，请联系技术人员！",function(index){
                            layer.close(index);
                            gofocus();
                        });
                    },
                    beforeSend:function(){
                        loadingFlag = layer.load(0, {shade: false}); //0代表加载的风格，支持0-2
                    },
                    complete:function(){
                        layer.close(loadingFlag);
                    }
                });
            }
        });

    });

    
    function gofocus(){
        $("#key").val("");
        $("#key").focus();
    }

    function showhtml(errmsg,data){
        var formData = data.form_data;
        html='<ul class="list-group">';
        html+='<li class="list-group-item">状态： '+errmsg+'</li>';
        html+='<li class="list-group-item">核销码： '+data.hexiaoma+'</li>';
        html+='<li class="list-group-item">姓名： '+data.realname+'</li> ';
        html+='<li class="list-group-item">手机： '+data.mobile+'</li> ';
        html+='<li class="list-group-item">身份证号码： '+data.form_data_common.idcard+'</li> ';
        for(var x in formData){
            html+='<li class="list-group-item">'+formData[x].title+'： '+formData[x].data+'</li> ';
        }
        // html+='<li class="list-group-item">身份证： '+data.title+'</li> ';
        // html+='<li class="list-group-item">性别： '+data.title+'</li> ';
        // html+='<li class="list-group-item">是否去过疫情高风险地区： '+data.title+'</li> ';
        // html+='<li class="list-group-item">预约时间段： '+data.title+'</li> ';
        // html+='<li class="list-group-item">随行儿童(姓名)： '+data.title+'</li> ';
        // html+='<li class="list-group-item">儿童身份证号码： '+data.title+'</li> ';
        html=html +'</ul>';
        $("#info").empty();
        $("#info").append(html);
        $("#info").show();
    }

</script>
</body>
</html>